//
//  ViewController.m
//  TestIOS
//
//  Created by 吴俊东 on 16/4/16.
//  Copyright © 2016年 JD. All rights reserved.
//

#import "ViewController.h"
#import "Masonry.h"
#import "YYCache.h"

@interface ViewController ()


@end

@implementation ViewController


- (void)viewDidLoad {
    [super viewDidLoad];
//~~~~~~~this is one change
    
//~~~~~~~this is two change
    
//~~~~this is 3
    
}


- (void)testCach {
    YYCache *sCache = [YYCache cacheWithName:@"first"];
    NSLog(@"%@,%d,%@",sCache,[sCache containsObjectForKey:@"testImg"],[sCache objectForKey:@"testImg"]);
    if (sCache != nil && [sCache containsObjectForKey:@"testImg"]) {
        UIImage *img = [sCache objectForKey:@"testImg"];
        UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake((self.view.frame.size.width-300)/2, (self.view.frame.size.height-400)/2, 300, 400)];
        imgView.image = img;
        [self.view addSubview:imgView];
        
        NSLog(@"%@",img.description);
    }

}
- (void)initCache {
    UIImage *img = [UIImage imageNamed:@"testImg"];
    YYCache *cache = [[YYCache alloc] initWithName:@"first"];
    if(![cache containsObjectForKey:@"testImg"]){
        [cache setObject:img forKey:@"testImg" withBlock:^{
            NSLog(@"success");
            
        }];
        
    }
    UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, 300, 400)];
    imgView.image = img;
    [self.view addSubview:imgView];
}
@end
